#!/bin/bash
# $Id$
#
# Description: A Sigmonster, with mpd support 
#
# Copyright (C) 2003,2004,2005,2006 Charles Mauch <cmauch@gmail.com>
#
# Verbatim copying, distribution, and display of this program is permitted in
# any medium, provided this notice is preserved. Alternatively, you may create
# derivative works of any sort for any purpose, provided your versions contain
# no attribution to me, and that you assert your own authorship (and not mine)
# in every practical medium.


if (mpc | grep -q "playing") ; then
 ALBUM=`mpc --format %album% | head -n 1`
 ARTIST=`mpc --format %artist% | head -n 1`
 TITLE=`mpc --format %title% | head -n 1`
 export ALBUM ARTIST TITLE
 mpdstring="Playing \"$TITLE\" by $ARTIST ($ALBUM)"
 maxlength=72

 # Chomp long lines.  Otherwise they run on.
 if [ $(echo -n $mpdstring | wc -c | tr -d " ") -gt $maxlength ]
 then
  music="$(echo -n $mpdstring | sed -e "s/\(.\{$maxlength\}\).*/\1/")...)"
 else
  music=$mpdstring
 fi
 
else
 NOMUSIC=1 ; export NOMUSIC
fi


if [ $1 = "geek" ]; then
 echo "Take it easy, Charles"
 echo 
 echo "FSF Apologist, WikiNut, Concrete Analyst, etc."
 echo "EMAIL: $2 VOICE: (253) 397-1265 FWD: 752491"
 echo "SIP: charles@mauch.name, GIZMO: charlesmauch AIM: cmauch5"
 echo 
 echo "Every message PGP or S/MIME signed to verify authenticity."
 echo
 echo -n ":: "
 if [ ! "$NOMUSIC" = "1" ] ; then
  echo $music
  else
  signify
 fi
elif [ $1 = "prolist" ]; then
 echo "Regards,"
 echo " - Charles"
else
 echo "Take it easy, Charles"
 echo
 echo "EMAIL: $2 VOICE: (253) 397-1265 FWD: 752491"
 echo "SIP: charles@mauch.name, GIZMO: charlesmauch AIM: cmauch5"
 echo "Every message PGP or S/MIME signed to verify authenticity."
 echo
 echo -n ":: "
 if [ ! "$NOMUSIC" = "1" ] ; then
  echo $music
  else
  signify
 fi
fi
